package com.cloudfun.campusshare.service.handler;

import com.cloudfun.campusshare.common.model.dto.kjt.KjtNotifyBaseDTO;
import com.cloudfun.campusshare.common.model.dto.kjt.KjtSubMerchantWithdrawalCashNotifyDTO;
import com.cloudfun.campusshare.service.WithdrawApplicationService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 处理转账通知
 * Created by Huqin on 2020/8/17
 */
@Slf4j
@Component
public class KjtWithdrawStatusNotifyHandler implements KjtNotifyHandler<KjtSubMerchantWithdrawalCashNotifyDTO> {

    @Autowired
    private WithdrawApplicationService withdrawApplicationService;

    @Override
    public String notifyType() {
        return "withdrawal_status_sync";
    }

    @Override
    public Class<KjtSubMerchantWithdrawalCashNotifyDTO> notifyMessageType() {
        return KjtSubMerchantWithdrawalCashNotifyDTO.class;
    }

    @Override
    public boolean handle(KjtNotifyBaseDTO notifyMsg) {
        KjtSubMerchantWithdrawalCashNotifyDTO notifyDTO = (KjtSubMerchantWithdrawalCashNotifyDTO) notifyMsg;
        log.info("提现回调通知:{}",notifyMsg);
        return withdrawApplicationService.handleWithdrawNotify(notifyDTO);
    }
}
